/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pos.system.standard.ui.util;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import pos.system.database.DBConstant;

/**
 *
 * @author Shameera
 */
public class GuiUtil {

    private static int SCREEN_HEIGHT;
    private static int SCREEN_WIDTH;

    static {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension dim = toolkit.getScreenSize();
        SCREEN_HEIGHT = dim.height;
        SCREEN_WIDTH = dim.width;
    }

    public static void buttonFocusGained(JButton button) {
        button.setBackground(Color.WHITE);
    }

    public static void buttonFocusLost(JButton button) {
        button.setBackground(Color.LIGHT_GRAY);
    }

    public static void initMainPanel(JPanel panel) {
//        panel.setBackground(Color.getHSBColor(64, 48, 73));
    }

    public static int getScreenWidth() {
        return SCREEN_WIDTH;
    }

    public static int getScreenHeight() {
        return SCREEN_HEIGHT;
    }

    public static Dimension getDiamention() {
        return new Dimension(SCREEN_WIDTH, SCREEN_WIDTH);
    }

    public static void showErrorMessage(JComponent com, String message, String title) {
        JOptionPane.showMessageDialog(com, message, title, JOptionPane.ERROR_MESSAGE);
    }

    public static void showInfoMessage(JComponent com, String message, String title) {
        JOptionPane.showMessageDialog(com, message, title, JOptionPane.INFORMATION_MESSAGE);
    }

    public static void showWorningMessage(JComponent com, String message, String title) {
        JOptionPane.showMessageDialog(com, message, title, JOptionPane.WARNING_MESSAGE);
    }

    public static String getReportDate(String year, String month, String day) {
        String[] months = new String[]{"Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"};
        String m = "";
        for (int i = 0; i < months.length; i++) {
            if (months[i].equals(month)) {
                if (i + 1 > 9) {
                    m = "" + (i + 1);
                } else {
                    m = "0" + (i + 1);
                }
                break;
            }
        }
        if (day.equals("")) {
            return year + "-" + m;

        } else {
            return year + "-" + m + "-" + day;

        }
    }
}
